feat: add quickpay daily spend limit - #1159
Conversation
Greptile SummaryThe PR adds a persisted daily spending cap to QuickPay while retaining confirmation-free, PIN-free payments below the configured limits.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/repositories/QuickPayRepo.kt | Centralizes QuickPay sessions, spend reservation, payment dispatch, completion attribution, and LDK reconciliation. |
| app/src/main/java/to/bitkit/repositories/QuickPaySpendStore.kt | Implements the versioned daily ledger, local-day rollover, reservation persistence, settlement, and reconciliation. |
| app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt | Integrates daily-cap eligibility and QuickPay completion outcomes into scan routing and pending-payment handling. |
| app/src/main/java/to/bitkit/repositories/PendingPaymentRepo.kt | Adds keyed resolution caching so settlement occurring before pending-screen initialization can still be consumed. |
| app/src/main/java/to/bitkit/viewmodels/QuickPayViewModel.kt | Reworks QuickPay around repository-owned sessions and maps success, pending, fallback, and error events to UI state. |
| app/src/main/java/to/bitkit/ui/settings/quickPay/QuickPaySettingsScreen.kt | Adds the daily-limit multiplier slider and resolved daily-limit copy to QuickPay settings. |
| app/src/main/java/to/bitkit/ui/components/Slider.kt | Updates slider layout and tap behavior for labeled QuickPay threshold and multiplier controls. |
| app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt | Handles keyed QuickPay requests, fallback to Confirm, pending settlement amounts, and replacement navigation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Scan or paste Lightning request] --> B{QuickPay enabled and per-transaction threshold met?}
B -->|No| C[Confirm payment]
B -->|Yes| D{Daily ledger has capacity?}
D -->|No| C
D -->|Yes| E[Reserve spend by invoice hash]
E --> F[Dispatch Lightning payment]
F -->|Immediate success| G[Keep daily spend and show success with fee]
F -->|Pending| H[Track pending payment]
H -->|Later success| G
F -->|Attributed failure| I[Release matching-day reservation]
H -->|Later attributed failure| I
I --> J[Show payment failure]
Reviews (5): Last reviewed commit: "fix: resolve quickpay review findings" | Re-trigger Greptile
0807618 to
2e4a4c0
Compare
32b59a5 to
49ab192
Compare
2e4a4c0 to
7b9ea19
Compare
7b9ea19 to
f10f4e2
Compare
…-pin-for-quickpay
|
Retested. Previous findings are fixed:
New issue, both platforms: paying an invoice via QuickPay, then scanning/pasting that same invoice again, shows Bitcoin Sent / success again. LDK rejects it as already paid ( Recordings + logs attached. repeat.invoice.-.android.mov |
This comment was marked as outdated.
This comment was marked as outdated.
|
@piotr-iohk Fixed in 1f8525f. A fresh |
Closes #1168
iOS port:
QuickPay stays PIN-free under limits (the point of QuickPay). A hard payment-PIN skip would remove that behavior, so this PR bounds auto-pay with a daily spend multiplier instead. Payments above the daily cap open Confirm, where PIN for payments still applies. Lock-time deferral remains in #1158.
Description
1,3,5,10,50; default5)threshold × multiplierin USD cents; spend rolls forward on the local calendar daysignalCompletion; keep spend on success; release matching-day failure onlyQuickPayRepoowns sessions, in-flight ops, dispatch, and the daily-cap ledger.QuickPaySpendStoreis an internal class in the same file.Out of scope
Preview
Updated screenshot, integrating designer's feedback.
slider.mp4
1159-over-daily-cap-confirm-pin.mp4
QA Notes
Manual Tests
$copy updatesregression:Cold start / locked with PIN → scan stays deferred until unlock (fix: secure shop payments and locked links #1158), then follows the rules aboveAutomated Checks
QuickPayRepoTest.kt:reserveBoundsignalCompletionsuccess keeps spendsignalCompletionfailure rolls backsignalCompletionis idempotentQuickPayViewModelTest.kt:AppViewModelSendFlowTest.kt:signalCompletionPaymentFailedstill resolves PendingPendingPaymentRepoTest.kt:SendPendingViewModelTest.ktQuickPaySettingsScreenTest.kt